let formatSearchTemplate = (movie) => {
  return `<li class="flex items-center">
        <a href="/api/movie/detail?movieId=${movie.vod_id}" class="join border-spacing-2 flex gap-3 border hover:bg-gray-100 w-full">
            <img src="/placeholder.svg" alt="Artist" class="join-item h-20 w-20 object-cover"/>
            <div class="join-item mr-1 h-20 overflow-hidden text-ellipsis text-sm flex-grow">
                <h4 class="mb-1 text-xl font-semibold">${movie.vod_name} - ${movie.vod_id}</h4>
                <p class="text-gray-600">
                最新: ${movie.vod_remarks}
                <br/>
                更新时间: ${movie.vod_time}
                </p>
            </div>
        </a>
    </li>`;
}

let useSearchModal = (query) => {
  $.ajax({
    url: '/api/movie/info',
    method: 'GET',
    data: { action: 'query', movieName: query },
    dataType: 'json',
    success: function (response) {
      const movies = response.data
      const tableBody = $('#searchMovieList')
      tableBody.empty()
      movies.forEach(function (movie) {
        tableBody.append(formatSearchTemplate(movie))
      })
    }
  })
}
